<?php

/*
  ipn.php - example code used for the tutorial:

  PayPal IPN with PHP
  How To Implement an Instant Payment Notification listener script in PHP
  http://www.micahcarrick.com/paypal-ipn-with-php.html

  (c) 2011 - Micah Carrick
 */

// tell PHP to log errors to ipn_errors.log in this directory
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__) . '/ipn_errors.log');

// intantiate the IPN listener
include('ipnlistener.php');
$listener = new IpnListener();

// tell the IPN listener to use the PayPal test sandbox
$listener->use_sandbox = true;

// try to process the IPN POST
try {
    $listener->requirePostMethod();
    $verified = $listener->processIpn();
} catch (Exception $e) {
    error_log($e->getMessage());
    exit(0);
}
?>
